package com.ruoyi.security.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.security.mapper.AfRescueMapper;
import com.ruoyi.security.domain.AfRescue;
import com.ruoyi.security.service.IAfRescueService;

/**
 * 应急救援Service业务层处理
 *
 * @author cjie
 * @date 2021-07-24
 */
@Service
public class AfRescueServiceImpl implements IAfRescueService {
    @Autowired
    private AfRescueMapper afRescueMapper;

    /**
     * 查询应急救援
     *
     * @param id 应急救援ID
     * @return 应急救援
     */
    @Override
    public AfRescue selectAfRescueById(String id) {
        return afRescueMapper.selectAfRescueById(id);
    }

    /**
     * 查询应急救援列表
     *
     * @param afRescue 应急救援
     * @return 应急救援
     */
    @Override
    public List<AfRescue> selectAfRescueList(AfRescue afRescue) {
        return afRescueMapper.selectAfRescueList(afRescue);
    }

    /**
     * 新增应急救援
     *
     * @param afRescue 应急救援
     * @return 结果
     */
    @Override
    public int insertAfRescue(AfRescue afRescue) {
        afRescue.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        afRescue.setCreateTime(DateUtils.getNowDate());
        afRescue.setCreateBy(SecurityUtils.getUsername());
        return afRescueMapper.insertAfRescue(afRescue);
    }

    /**
     * 修改应急救援
     *
     * @param afRescue 应急救援
     * @return 结果
     */
    @Override
    public int updateAfRescue(AfRescue afRescue) {
        afRescue.setUpdateTime(DateUtils.getNowDate());
        afRescue.setUpdateBy(SecurityUtils.getUsername());
        return afRescueMapper.updateAfRescue(afRescue);
    }

    /**
     * 批量删除应急救援
     *
     * @param ids 需要删除的应急救援ID
     * @return 结果
     */
    @Override
    public int deleteAfRescueByIds(String[] ids) {
        return afRescueMapper.deleteAfRescueByIds(ids);
    }

    /**
     * 删除应急救援信息
     *
     * @param id 应急救援ID
     * @return 结果
     */
    @Override
    public int deleteAfRescueById(String id) {
        return afRescueMapper.deleteAfRescueById(id);
    }
}
